<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户列表</title>
</head>
<body>
<form action="/UserServlet">
    管理员用户名：<input type="text" id="username" name="username">
    管理员密码：<input type="password" id="password" name="password">
    <input type="button" onclick="find()"><br>

    <span id="msg"></span>

    <table id="userTable">

        <tr>
            <th>姓名</th>
            <th>密码</th>
        </tr>
    </table>
</form>
</body>
<script>


    function find() {
        console.log("方法");
        let username = document.getElementById("username").value;
        let password = document.getElementById("password").value;
        let table = document.getElementById("userTable");
        let msg = document.getElementById("msg");
        let userJson = {username: username, password: password};
        let url = "UserServlet";
        axios.post(url, userJson).then(resp => {
            if (resp.data.flag) {
            msg.innerHTML = resp.data.msg;
                let str ="";
                for (let user of resp.data.data) {
                    str +=`<tr>
                        <th>${user.username}</th>
                        <th>${user.password}</th>
                       </tr>`;
                }
                table.innerHTML += str
            } else {
            msg.innerHTML = resp.data.msg;
            }
        })

    }


</script>
<script src="js/axios-0.18.0.js"></script>
</html>